﻿// -----------------------------------------------------------------------
// <copyright file="CustomerShowCommand.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace ShopShell.Commands
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Input;
    using Microsoft.Practices.Unity;
    using Microsoft.Practices.Prism.Regions;
   // using ModuleCustomer.View;
    using Microsoft.Practices.ServiceLocation;
    using ShellInfrastructure;
    using ModuleCustomer.View;
    using Microsoft.Practices.Prism.Events;
    using EventInfrastructure;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class CustomerShowCommand : ICommand
    {
        [Dependency]
        public IRegionManager RegionManager { get; set; }

        [Dependency]
        public IEventAggregator EventAggregator { get; set; }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            EventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
            RegionManager = ServiceLocator.Current.GetInstance<IRegionManager>();



            IRegion region = RegionManager.Regions[RegionNames.LeftRegionName];
            ICustomerViewList obj = ServiceLocator.Current.GetInstance<ICustomerViewList>();

            Dictionary<string, object> filter = new Dictionary<string, object>();
            filter.Add("place", ServerConnection.Service.PlaceId);

            obj.Refresh(filter);
            region.Activate(obj);
            EventAggregator.GetEvent<SelectCategoryEvent>().Publish(true);
        }
    }
}
